import {Module} from 'vuex'
// import {createStorage} from '@/utils/Storage'
// import {login, getUserInfo, logout} from '@/api/system/user'
import {ACCESS_TOKEN, CURRENT_USER} from '@/store/mutation-types'
// import { welcome } from '@/utils/util'

// const Storage = createStorage({storage: localStorage})

const state = {
    token: '',
    name: '',
    welcome: '',
    avatar: '',
    roles: [],
    info:{}
}

type StateType = typeof state

const user: Module<StateType, any> = {
    namespaced: true,
    state,
    mutations: {
        SET_TOKEN: (state, token) => {
            state.token = token
        },
        SET_NAME: (state, {name, welcome}) => {
            state.name = name
            state.welcome = welcome
        },
        SET_AVATAR: (state, avatar) => {
            state.avatar = avatar
        },
        SET_ROLES: (state, roles) => {
            state.roles = roles
        },
        SET_INFO: (state, info) => {
            state.info = info
        }
    },

    actions: {}

}

export default user
